/**
 * Player class to play media files
 *
 * This is the class played a critical roles in music-engine player
 * It control all the activities when playing media files
 *
 * @copyright  hoatle (hoatle.net)
 * @author     hoatle
 * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version    1.0-alpha
 * @link       http://hoatle.net/Project-Music-Engine
 * @since      Class available since Release 1.0-alpha
 * $Id: Player.js 4 2009-01-16 12:03:30Z hoatlevan $
 */

/**
 * #include "PlayList.js"
 * #include "Song.js"
 * #include "Menu.js"
 */


/**
 * class Player
 * Player Constructor
 *
 * @param settings MAP
 * @return Player player
 */

Player = function(opt_params) {
    this._init(opt_params);
    return this;
}

/**
 * Enum for Player Mode
 */
Player.prototype.mode = {
    // This is the default player mode
    "PLAYLIST_REPEAT_ONCE" : "playlist-repeate-once",
    "PLAYLIST_REPEAT_ALL" : "playlist-repeate-all",
    "SONG_REPEATE_ONCE" : "song-repeate-once",
    "PLAYLIST_SHUFFLE" : "playlist-shuffle"
};


/**
 * _init sets all Player attributes to their default value. Make sure to call this
 * method within your class constructor
 */
Player.prototype._init = function(opt_params) {
    /**
     * PlayList Object
     */
    this.playlist = null;
    if (!opt_params.playlist) {
        this.playlist = opt_params.playlist;
    }
     /**
     * Song Object
     */
    this.currentSong = null;
    if (!opt_params.currentSong) {
        this.currentSong = opt_params.currentSong;
    }
    /**
     * Enum playMode
     */
    this.playMode = Player.mode.PLAYLIST_REPEAT_ONCE;

    // TODO: Check valid playMode from opt_params
    /*
     *
     */
    
    /**
     * swfPath for the swf player
     */
    this.swfPath = "";
    if (!opt_params.swfPath) {
        this.swfPath = opt_params.swfPath;
    }
    /**
     * Player version
     */
    this.version = "1.0-alpha";

    /**Aggregations: */

    /**Compositions: */

}

/**
 * Get the playlist
 *
 * @return PlayList playlist
 */
Player.prototype.getPlaylist = function() {
    return this.playlist;
}


/**
 * Get the current (selected) playing song
 *
 * @return Song currentSong
 */
Player.prototype.getCurrentSong = function() {
    return this.currentSong;
}


/**
 * Get song from playlist
 *
 * @param int songIndex
 * @return Song song
 */
Player.prototype.getSong = function(songIndex) {
    
}


/**
 * Play selected song
 *
 * @return true if succeeded else false
 */
Player.prototype.play = function () {
    
}


/**
 * Pause selected song
 *
 * @return true if succeeded else false
 */
Player.prototype.pause = function() {
    
}


/**
 * Add song the the playlist.
 * 
 * If song existed in the playlist, return false
 *
 * @param Song song
 * @return true if succeeded, else false
 */
Player.prototype.add = function(song) {
    
}


/**
 * Remove song from playlist
 *
 * If song not existed return false, else return true
 * @param song
 * @return true if succeeded, else false
 */
Player.prototype.remove = function(song) {
    
}


/**
 * Play the song, if song not existed in playlist, add it
 * @param song
 * @return true on succeeded or return false on error
 */
Player.prototype.playSong = function(song) {
    
}


/**
 * Stop play all the songs from playlist
 * The selected song will be reset to the first song from playlist
 * @return true on succeeded, else false when error
 */
Player.prototype.stop = function() {
    
}